from appium.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.common.by import By

from weekend.calculator1.base.basepage import BasePage


class Caculator(BasePage):

    def caculator(self):
        # 点击操作数
        self.find_and_click(AppiumBy.ID, value="com.android.calculator2:id/digit_8")
        # 点击符号
        self.find_and_click(AppiumBy.ACCESSIBILITY_ID, value="multiply")
        # 点击操作数
        self.find_and_click(AppiumBy.ID, value="com.android.calculator2:id/digit_3")
        # 点击等号
        self.find_and_click(AppiumBy.ACCESSIBILITY_ID, value="equals")
        # 获取搜索结果
        result = self.find_by_element(By.XPATH, "//*[@resource-id='com.android.calculator2:id/result']")
        result_content = int(result.text)
        return result_content








